package com.alliance.shuwei.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
@Table(name = "user")
@JsonInclude(Include.NON_NULL)
public class User extends Auditable {
	@Id
	@GeneratedValue
	@Column(name = "user_id")
	private Integer id;
	private String name;
	private String password;
	private Boolean isActive;
	@ManyToMany
	@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
	private List<Role> roles;
	@Embedded
	private ContactInfo contactInfo;
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "user_resource_provider", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "resource_provider_id"))
	private List<ResourceProvider> resourceProviders;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean isActive() {
		return isActive;
	}

	public void setActive(Boolean isActive) {
		this.isActive = isActive;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public ContactInfo getContactInfo() {
		return contactInfo;
	}

	@JsonProperty("contact_info")
	public void setContactInfo(ContactInfo contactInfo) {
		this.contactInfo = contactInfo;
	}

	public List<ResourceProvider> getResourceProviders() {
		return resourceProviders;
	}

	@JsonProperty("resource_providers")
	public void setResourceProviders(List<ResourceProvider> resourceProviders) {
		this.resourceProviders = resourceProviders;
	}

}
